<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Test</title>
</head>
<body>
  <div>
    <button id="btn">promise 打开window</button>
  </div>
  <script>
    const btn = document.querySelector('#btn');
    btn.addEventListener('click', () => {
      var xhr = new XMLHttpRequest();
      xhr.open('get', '/');
      xhr.send('12');
      xhr.onreadystatechange = () => {
        if (xhr.readyState === 4) {
          setTimeout(() => {
            window.open('https://www.baidu.com', 'blank1');
          }, 1000);
        }
      };
    });
  </script>
</body>
</html>
